
package fy.bean;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import fy.util.DBUtil;

public class WhzbBean {
	private int id;
	private String category;
	private String title;
	private String content;
	private int homepage;
	private Date time;
	private String author;
	private String picture;
	private String source;
	private String externallinks;
	private int puton;
	private String categoryname;
	
	
	PreparedStatement statement=null;
	ResultSet rs = null;
	Connection connection = null;
	
	
	public String getCategoryname() {
		return categoryname;
	}
	public void setCategoryname(String categoryname) {
		this.categoryname = categoryname;
	}
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}


	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String tittle) {
		this.title = tittle;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public int getHomepage() {
		return homepage;
	}
	public void setHomepage(int homepage) {
		this.homepage = homepage;
	}
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public String getPicture() {
		return picture;
	}
	public void setPicture(String picture) {
		this.picture=picture;
	}
	public String getExternallinks() {
		return externallinks;
	}
	public void setExternallinks(String externallinks) {
		this.externallinks=externallinks;
	}
	
	public int getPuton() {
		return puton;
	}
	public void setPuton(int puton) {
		this.puton = puton;
	}
	
	
	
	//首页查询
	public List<WhzbBean> findOnindexbylb(String lbString) {
		System.out.println("run findAllByLb " + lbString);
		List<WhzbBean> list = new ArrayList<WhzbBean>();
		DBUtil dbUtil = new DBUtil();
		connection = dbUtil.geConnection();
		String sql = "select * from whzb where category = ? and homepage=1 and puton=1 order by time desc ";
		try {
			statement = connection.prepareStatement(sql);
			statement.setString(1, lbString);
			rs = statement.executeQuery();
			while (rs.next()) {
				WhzbBean whzb = new WhzbBean();
				whzb.setId(rs.getInt("id"));
				whzb.setTitle(rs.getString("title"));
				whzb.setContent(rs.getString("content"));
				whzb.setTime(rs.getDate("time"));
				whzb.setPicture(rs.getString("picture"));
				whzb.setExternallinks(rs.getString("externallinks"));
				whzb.setAuthor(rs.getString("author"));
				whzb.setCategory(rs.getString("category"));
				whzb.setSource(rs.getString("source"));
				whzb.setHomepage(rs.getInt("homepage"));
				whzb.setCategoryname(rs.getString("categoryname"));
				whzb.setPuton(rs.getInt("puton"));
				list.add(whzb);
				System.out.println("findAllByLb  " + whzb);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if(connection != null) {
				try {
					connection.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			dbUtil.close();
		}
		return list;
		
	}
	
	
	
	//前端查找类别
	public List<WhzbBean> findAllByLb(String lbString) {
		System.out.println("run findAllByLb " + lbString);
		List<WhzbBean> list = new ArrayList<WhzbBean>();
		DBUtil dbUtil = new DBUtil();
		connection = dbUtil.geConnection();
		String sql = "select * from whzb where category = ? and puton=1 ";
		try {
			statement = connection.prepareStatement(sql);
			statement.setString(1, lbString);
			rs = statement.executeQuery();
			while (rs.next()) {
				WhzbBean whzb = new WhzbBean();
				whzb.setId(rs.getInt("id"));
				whzb.setTitle(rs.getString("title"));
				whzb.setContent(rs.getString("content"));
				whzb.setTime(rs.getDate("time"));
				whzb.setPicture(rs.getString("picture"));
				whzb.setExternallinks(rs.getString("externallinks"));
				whzb.setAuthor(rs.getString("author"));
				whzb.setCategory(rs.getString("category"));
				whzb.setSource(rs.getString("source"));
				whzb.setHomepage(rs.getInt("homepage"));
				whzb.setCategoryname(rs.getString("categoryname"));
				whzb.setPuton(rs.getInt("puton"));
				list.add(whzb);
				System.out.println("findAllByLb  " + whzb);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if(connection != null) {
				try {
					connection.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			dbUtil.close();
		}
		return list;
		
	}
	//后端页面通过类别查找
	public List<WhzbBean> findbackByLb(String lbString) {
		System.out.println("run findAllByLb " + lbString);
		List<WhzbBean> list = new ArrayList<WhzbBean>();
		DBUtil dbUtil = new DBUtil();
		connection = dbUtil.geConnection();
		String sql = "select * from whzb where category = ?";
		try {
			statement = connection.prepareStatement(sql);
			statement.setString(1, lbString);
			rs = statement.executeQuery();
			while (rs.next()) {
				WhzbBean whzb = new WhzbBean();
				whzb.setId(rs.getInt("id"));
				whzb.setTitle(rs.getString("title"));
				whzb.setContent(rs.getString("content"));
				whzb.setTime(rs.getDate("time"));
				whzb.setPicture(rs.getString("picture"));
				whzb.setExternallinks(rs.getString("externallinks"));
				whzb.setAuthor(rs.getString("author"));
				whzb.setCategory(rs.getString("category"));
				whzb.setSource(rs.getString("source"));
				whzb.setHomepage(rs.getInt("homepage"));
				whzb.setCategoryname(rs.getString("categoryname"));
				whzb.setPuton(rs.getInt("puton"));
				list.add(whzb);
				System.out.println("findAllByLb  " + whzb);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if(connection != null) {
				try {
					connection.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			dbUtil.close();
		}
		return list;
		
	}
	//查找ID
public WhzbBean findNewsById(int id) {
		
		DBUtil dbUtil = new DBUtil();
		connection = dbUtil.geConnection();
		WhzbBean whzb1 = new WhzbBean();
		String sql = "select * from whzb where id = ? and puton=1";
		try {
			statement = connection.prepareStatement(sql);
			statement.setInt(1, id);
			rs = statement.executeQuery();
			
			if(rs.next()) {
				whzb1.setId(rs.getInt("id"));
				whzb1.setTitle(rs.getString("title"));
				whzb1.setContent(rs.getString("content"));
				whzb1.setTime(rs.getDate("time"));
				whzb1.setAuthor(rs.getString("author"));
				whzb1.setCategory(rs.getString("category"));
				whzb1.setSource(rs.getString("source"));
				whzb1.setHomepage(rs.getInt("homepage"));
				whzb1.setCategoryname(rs.getString("categoryname"));
				whzb1.setExternallinks(rs.getString("externallinks"));
				whzb1.setCategoryname(rs.getString("categoryname"));
				whzb1.setPuton(rs.getInt("puton"));
				whzb1.setPicture(rs.getString("picture"));
			}
			
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if(connection != null) {
				try {
					connection.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			dbUtil.close();
		}
	
		return whzb1;
		
	}

public List<WhzbBean> findAllByLbForPX(String lbString) {
	System.out.println("run findAllByLb " + lbString);
	List<WhzbBean> list = new ArrayList<WhzbBean>();
	DBUtil dbUtil = new DBUtil();
	connection = dbUtil.geConnection();
	String sql = "select * from whzb where category = ? and puton=1 order by time desc";
	try {
		statement = connection.prepareStatement(sql);
		statement.setString(1, lbString);
		rs = statement.executeQuery();
		while (rs.next()) {
			WhzbBean whzb = new WhzbBean();
			whzb.setId(rs.getInt("id"));
			whzb.setTitle(rs.getString("title"));
			whzb.setContent(rs.getString("content"));
			whzb.setTime(rs.getDate("time"));
			whzb.setPicture(rs.getString("picture"));
			whzb.setExternallinks(rs.getString("externallinks"));
			whzb.setAuthor(rs.getString("author"));
			whzb.setCategory(rs.getString("category"));
			whzb.setHomepage(rs.getInt("homepage"));
			whzb.setExternallinks(rs.getString("externallinks"));
			whzb.setCategoryname(rs.getString("categoryname"));
			whzb.setPuton(rs.getInt("puton"));
			list.add(whzb);
			System.out.println("findAllByLb  " + whzb);
		}
		
	} catch (Exception e) {
		e.printStackTrace();
	}finally {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if (statement != null) {
			try {
				statement.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(connection != null) {
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		dbUtil.close();
	}
	return list;
	
}

//查找上一页的ID
public WhzbBean findPreNewsById(List<WhzbBean> listWhzbBean, int id) {
	WhzbBean whzb = null;
	for(int i=0;i<listWhzbBean.size();i++) {
		if(id == listWhzbBean.get(i).getId()&&i!=0) {
			whzb = listWhzbBean.get(i-1);
			return whzb;
		}
	}
	return whzb;
	 
	}


public WhzbBean findNextNewsById(List<WhzbBean> listWhzbBean,int id) {
	WhzbBean whzb = null;
	for(int i=0;i<listWhzbBean.size();i++) {
		if(id == listWhzbBean.get(i).getId()&&i+1<listWhzbBean.size()) {
			whzb = listWhzbBean.get(i+1);
			return whzb;
		}
	}
	return whzb;
	 
	 
	}

//增加内容
	public boolean doAdd(String category,String title,String content,Integer homepage,String picture,String author,String source,String txtDate,Integer puton,String externallinks,String categoryname) {
		boolean add = false;
		DBUtil dbUtil = new DBUtil();
		connection = dbUtil.geConnection();
		//String sql = "select password from admin where username = " + username + "'";
		String sql = "insert into whzb(category,title,content,homepage,picture,author,source,time,puton,externallinks,categoryname) values(?,?,?,?,?,?,?,?,?,?,?)";
		
	  try {		
		  PreparedStatement statement = connection.prepareStatement(sql);
			statement.setString(1, category);
			statement.setString(2, title);
			statement.setString(3, content);
			statement.setInt(4, homepage);
			statement.setString(5, picture);
			statement.setString(6, author);
			statement.setString(7, source);
			statement.setString(8, txtDate);
			statement.setInt(9, puton);
			statement.setString(10, externallinks);
			statement.setString(11, categoryname);
			System.out.println(add);
			int i = statement.executeUpdate();
			if (i>0) {
				add = true;
			}
				
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if(connection != null) {
				try {
					connection.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			dbUtil.close();
		}
		return add;
	}

	//模糊查询
		public List<WhzbBean> Proselect(String lbString,String tilString,Page page) {
			  List<WhzbBean> list =new ArrayList<WhzbBean>();
			  DBUtil dbUtil = new DBUtil();
			  connection = dbUtil.geConnection();
			  //String sql = "select * from news";
			  String sql ="select * from whzb where category =? and concat(id,title,content,category,author,source,time,puton) like ? order by time desc limit ?,?" ;
			  connection = dbUtil.geConnection();
			  try {
			   statement = connection.prepareStatement(sql);
			   statement.setString(1, lbString);
			     statement.setString(2,"%" + tilString + "%");
			     statement.setInt(3, page.getBeginIndex());
			     statement.setInt(4, page.getEveryPage());
			   rs = statement.executeQuery();
			   while(rs.next()) {
				   WhzbBean whzb = new WhzbBean();
				   whzb.setId(rs.getInt("id"));
				   whzb.setTitle(rs.getString("title"));
				   whzb.setContent(rs.getString("content"));
				   whzb.setCategory(rs.getString("category"));
				   whzb.setAuthor(rs.getString("author"));
				   whzb.setSource(rs.getString("source"));
				   whzb.setTime(rs.getDate("time"));
				   whzb.setPicture(rs.getString("picture"));
				   whzb.setPuton(rs.getInt("puton"));
				   whzb.setHomepage(rs.getInt("homepage"));
				   whzb.setCategoryname(rs.getString("categoryname"));
				   whzb.setPuton(rs.getInt("puton"));
			    list.add(whzb);
			   }
			   
			  } catch (SQLException e) {
			   e.printStackTrace();
			  }finally {
			   if (rs != null) {
			    try {
			     rs.close();
			    } catch (SQLException e) {
			     e.printStackTrace();
			    }
			   }
			   if (statement != null) {
			    try {
			     statement.close();
			    } catch (SQLException e) {
			     e.printStackTrace();
			    }
			   }
			   if(connection != null) {
			    try {
			     connection.close();
			    } catch (SQLException e) {
			     e.printStackTrace();
			    }
			   }
			   dbUtil.close();
			  }
			  return list;
			 }
	//总页数
	public int findCountByLb(String lbString) {
		List<WhzbBean> list = new ArrayList<WhzbBean>();
		DBUtil dbUtil = new DBUtil();
		connection = dbUtil.geConnection();
		int count = 0;
		String sql = "select count(*) totalCount from whzb where category =? and puton=1";
		try {
			statement = connection.prepareStatement(sql);
			statement.setString(1, lbString);
			rs = statement.executeQuery();
			if (rs.next()) {
				count=rs.getInt("totalCount");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally {
			if (rs != null) {
				try {
					rs.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if (statement != null) {
				try {
					statement.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			if(connection != null) {
				try {
					connection.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			dbUtil.close();
		}
		return count;
		
	}
	
//分页
public List<WhzbBean> findAllByLbForFY(String lbString,Page page) {
	List<WhzbBean> list = new ArrayList<WhzbBean>();
	DBUtil dbUtil = new DBUtil();
	connection = dbUtil.geConnection();
	String sql = "select * from whzb where category =? and puton=1 order by time desc limit ?,?";
	try {
		statement = connection.prepareStatement(sql);
		statement.setString(1, lbString);
		statement.setInt(2, page.getBeginIndex());
		statement.setInt(3, page.getEveryPage());
		rs = statement.executeQuery();
		while(rs.next()) {
			WhzbBean whzb = new WhzbBean();
			whzb.setCategory(rs.getString("category"));
			whzb.setId(rs.getInt("id"));
			whzb.setTitle(rs.getString("title"));
			whzb.setContent(rs.getString("content"));
			whzb.setAuthor(rs.getString("author"));
			whzb.setTime(rs.getDate("time"));
			whzb.setPicture(rs.getString("picture"));
			whzb.setExternallinks(rs.getString("externallinks"));
			whzb.setHomepage(rs.getInt("homepage"));
			whzb.setPuton(rs.getInt("puton"));
			System.out.println(whzb.getPicture());
			list.add(whzb);
		}
		
	} catch (SQLException e) {
		e.printStackTrace();
	}finally {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if (statement != null) {
			try {
				statement.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(connection != null) {
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		dbUtil.close();
	}
	return list;
	
}
//后端查询总数
public int findbackCountByLb(String lbString) {
	List<WhzbBean> list = new ArrayList<WhzbBean>();
	DBUtil dbUtil = new DBUtil();
	connection = dbUtil.geConnection();
	int count = 0;
	String sql = "select count(*) totalCount from whzb where category =?";
	try {
		statement = connection.prepareStatement(sql);
		statement.setString(1, lbString);
		rs = statement.executeQuery();
		if (rs.next()) {
			count=rs.getInt("totalCount");
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}finally {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if (statement != null) {
			try {
				statement.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(connection != null) {
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		dbUtil.close();
	}
	return count;
	
}
//后端分页
public List<WhzbBean> findbackByLbForFY(String lbString,Page page) {
	List<WhzbBean> list = new ArrayList<WhzbBean>();
	DBUtil dbUtil = new DBUtil();
	connection = dbUtil.geConnection();
	String sql = "select * from whzb where category =? order by time desc limit ?,?";
	try {
		statement = connection.prepareStatement(sql);
		statement.setString(1, lbString);
		statement.setInt(2, page.getBeginIndex());
		statement.setInt(3, page.getEveryPage());
		rs = statement.executeQuery();
		while(rs.next()) {
			WhzbBean whzb = new WhzbBean();
			whzb.setCategory(rs.getString("category"));
			whzb.setId(rs.getInt("id"));
			whzb.setTitle(rs.getString("title"));
			whzb.setContent(rs.getString("content"));
			whzb.setAuthor(rs.getString("author"));
			whzb.setTime(rs.getDate("time"));
			whzb.setPicture(rs.getString("picture"));
			whzb.setSource(rs.getString("source"));
			whzb.setCategoryname(rs.getString("categoryname"));
			whzb.setHomepage(rs.getInt("homepage"));
			whzb.setPuton(rs.getInt("puton"));
			System.out.println(whzb.getPicture());
			list.add(whzb);
		}
		
	} catch (SQLException e) {
		e.printStackTrace();
	}finally {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if (statement != null) {
			try {
				statement.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(connection != null) {
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		dbUtil.close();
	}
	return list;
	
}
//后端模糊查询后总数
public int findselectCountByLb(String lbString,String tilString) {
	DBUtil dbUtil = new DBUtil();
	connection = dbUtil.geConnection();
	int count = 0;
	String sql = "select count(*) totalCount from whzb where category =? and concat(id,title,content,category,author,source,time,puton) like ? ";
	try {
		statement = connection.prepareStatement(sql);
		statement.setString(1, lbString);
		statement.setString(2,"%" + tilString + "%");
		rs = statement.executeQuery();
		if (rs.next()) {
			count=rs.getInt("totalCount");
			System.out.print("totalCount :"+count);
		}
		
	} catch (SQLException e) {
		e.printStackTrace();
	}finally {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if (statement != null) {
			try {
				statement.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(connection != null) {
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		dbUtil.close();
	}
	return count;
	
}
public List<WhzbBean> findAllByProForFY(String tilString,Page page) {
	List<WhzbBean> list = new ArrayList<WhzbBean>();
	DBUtil dbUtil = new DBUtil();
	connection = dbUtil.geConnection();
	String sql = "select * from whzb where concat(id,title,content,category,author,time,picture,homepage,puton) like ? limit ?,?";
	try {
		 statement = connection.prepareStatement(sql);
		   statement.setString(1,"%" + tilString + "%");
		statement.setInt(2, page.getBeginIndex());
		statement.setInt(3, page.getEveryPage());
		rs = statement.executeQuery();
		while(rs.next()) {
			WhzbBean whzb = new WhzbBean();
			whzb.setCategory(rs.getString("category"));
			whzb.setId(rs.getInt("id"));
			whzb.setTitle(rs.getString("title"));
			whzb.setContent(rs.getString("content"));
			whzb.setAuthor(rs.getString("author"));
			whzb.setTime(rs.getDate("time"));
			whzb.setPicture(rs.getString("picture"));
			whzb.setHomepage(rs.getInt("homepage"));
			whzb.setPuton(rs.getInt("puton"));
			System.out.println(whzb.getPicture());
			list.add(whzb);
		}
		
	} catch (SQLException e) {
		e.printStackTrace();
	}finally {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if (statement != null) {
			try {
				statement.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(connection != null) {
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		dbUtil.close();
	}
	return list;
	
}

public boolean doDel(int id) {
	boolean del = false;
	DBUtil dbUtil = new DBUtil();
	connection = dbUtil.geConnection();
	//String sql = "select password from admin where username = " + username + "'";
	String sql = "delete from whzb where id =?";
	try {
		statement = connection.prepareStatement(sql);
		statement.setInt(1, id);
		int i = statement.executeUpdate();
		if (i>0) {
			del = true;
		}
			
	} catch (SQLException e) {
		e.printStackTrace();
	}finally {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if (statement != null) {
			try {
				statement.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(connection != null) {
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		dbUtil.close();
	}
	return del;
	
}
public boolean doUpdata(String category,String title,String content,String picture,String author,int homepage,String source,String txtDate,Integer puton,String externallinks,String categoryname,int id) {
	System.out.println("1"+category+title+content+id);
	boolean updata = false;
	DBUtil dbUtil = new DBUtil();
	connection = dbUtil.geConnection();
	//String sql = "select password from admin where username = " + username + "'";
	String sql = "update whzb set category=?,title=?,content=?,picture=?,author=?,homepage=?,source=?,time=?,puton=?,externallinks=?,categoryname=? where id=?";
	
	try {
		statement = connection.prepareStatement(sql);
		statement.setString(1, category);
		statement.setString(2, title);
		statement.setString(3, content);
		statement.setString(4, picture);
		statement.setString(5, author);
		statement.setInt(6, homepage);
		statement.setString(7, source);
		statement.setString(8, txtDate);
		statement.setInt(9, puton);
		statement.setString(10, externallinks);
		statement.setString(11, categoryname);
		statement.setInt(12, id);
		int i = statement.executeUpdate();
		if (i>0) {
			updata = true;
		}
			
	} catch (SQLException e) {
		e.printStackTrace();
	}finally {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if (statement != null) {
			try {
				statement.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(connection != null) {
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		dbUtil.close();
	}
	return updata;
	
}

	
	@Override
	public String toString() {
		return "whzb [id=" + id + ", category=" + category + ", title=" + title + ", content=" + content
				+ ", homepage=" + homepage + ",picture="
				+ picture + ",]";
	}
	
	public static void main(String[] args) {
		
	}
	
	
}

